package com.fzf.org.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzf.org.dao.entities.AdminDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AdminMapper extends BaseMapper<AdminDO> {

    /**
     * 需要在使用前保证传入的列表不会空且长度大于0
     * @param accounts 用户 账号 列表
     * @return
     */
    @Update({
            "<script>",
            "UPDATE t_admin",
            "SET online = false",
            "WHERE account IN",
            "<foreach collection='accounts' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    int batchUpdateOnlineToFalse(@Param("accounts") List<String> accounts);

}